<?php

namespace app\admin\controller;

class Appdown extends Base
{
    public function index()
    {
        $result = model("appdownload")->getappdownloadlist();
        $this->assign("data", $result);
        return $this->fetch();
    }

    public function add()
    {
        $data = input();
        $result = model("appdownload")->add($data);
        if ($result == 1) {
            return $this->success("添加成功");
        } else {
            return $this->error($result);
        }
    }

    public function edit()
    {
        if (request()->isAjax()) {
            $data = input();
            $result = model("appdownload")->edit($data);
            if ($result == 1) {
                return $this->success("修改成功");
            } else {
                return $this->error($result);
            }
        } else {
            $id = input("id");
            if ($id == "") {
                $this->error("服务器错误");
            }
            $result = model("appdownload")->getappdownloadinfo($id);
            if ($result == null) {
                $this->error("服务器错误");
            }
            $this->assign("data", $result);
            return $this->fetch();
        }
    }
}
